package utils;

import java.util.ResourceBundle;

public class BeansFactory {
    public static Object getBeans(String beanName){
        //读取配置
        ResourceBundle rh = ResourceBundle.getBundle("beans");
        //获取配置参数字节码文件路径
        String classPath = rh.getString(beanName);
        //反射创建对象
        Object o = null;
        try {
            o = Class.forName(classPath).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
             e.printStackTrace();
        }
        return o;
    }
}
